package cn.cttic.app.mapper;

import cn.cttic.app.api.domain.vo.MobileInstallOrderInfoVo;
import cn.cttic.order.api.domain.BaseInstallOrder;
import cn.cttic.order.api.domain.vo.BaseInstallOrderVo;
import cn.cttic.order.api.domain.vo.BaseSaleOrderVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 安装Mapper接口
 *
 * @author Times.Studio
 * @date 2024-05-23
 */
public interface AppInstallMapper {

    @Select("<script>" +
        "SELECT\n" +
        "	installOrder.*, installOrder.status as installStatus \n" +
        "FROM\n" +
        "	base_install_order installOrder\n" +
        "	INNER JOIN base_sale_order saleOrder ON saleOrder.id = installOrder.sale_order_id\n" +
        "	INNER JOIN base_product product ON product.id = saleOrder.product_id\n" +
        "	INNER JOIN base_device device ON device.id = product.device_id\n" +
        "${ew.customSqlSegment}" +
        "</script>")
    Page<BaseInstallOrderVo> searchPageList(Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper);

    @Select("<script>" +
        "SELECT\n" +
        "	installOrder.id as orderId, \n" +
        "	product.id as productId, \n" +
        "	product.product_name as productName, \n" +
        "	product.product_thumbnail as productThumbnailId, \n" +
        "	device.id as deviceId, \n" +
        "	device.device_name as deviceName, \n" +
        "	saleOrder.last_name as customerName, \n" +
        "	saleOrder.phone as customerPhone, \n" +
        "	saleOrder.car_no as customerCarNo, \n" +
        "	installOrder.install_code as customerInstallCode, \n" +
        "	installOrder.status as orderStatus \n" +
        "FROM\n" +
        "	base_install_order installOrder\n" +
        "	INNER JOIN base_sale_order saleOrder ON saleOrder.id = installOrder.sale_order_id\n" +
        "	INNER JOIN base_product product ON product.id = saleOrder.product_id\n" +
        "	INNER JOIN base_device device ON device.id = product.device_id\n" +
        "${ew.customSqlSegment}" +
        "</script>")
    Page<MobileInstallOrderInfoVo> searchDetailPageList(Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper);
}
